package org.hagopa.games.moneypool.msgs;

public enum CommandsEnum {
	//Handshake commands
	SERV_HELLO	(100, "ServerHello",  1),
	INTRO		(120, "ClientIntro",  2),
	ACCEPT		(130, "Accept",       1),
	DENY        (140, "Deny",         1),
	READY		(160, "Ready",        2),
	UPDATE		(180, "Update",   	  1),
	////
	PLAY        (181,  "Play",        3),
	UPD_PLAYER  (182,  "PlayerUpdate",3),
	////
	//STATUS 		(200, "GetStatus",    2),
	//Game Commands
	
	THR_DIES    (400, "ThrowDies",    2),
	MOVE_DONE   (420, "MoveDone",     2),
	AC_NONE     (430, "NoAction",     2),
	AC_PAY      (440, "PayAction",    2),
	AC_BUY      (450, "BuyAction",    2),
	AC_SELL     (460, "SellAction",   2),
	AC_MORTGAGE (470, "Morgage",      2),
	AC_UPGRADE  (480, "Morgage",      2),
	END_TURN    (555, "EndTurn",      2),
	// End Game Commands 
	//Chat Commands
	CHAT_MSG    (150, "ChatMsg",      2),
	//BCHAT_MSG   (150, "BCChatMsg",    1),
	//--------------------------
	DISCONNECT  (999, "Disconnect",   2)
	;
	private int idx;
	private String name = null;
	private int type;
	
	CommandsEnum(int ind, String name, int type)
	{
		this.idx = ind;
		this.name = name;
		this.type = type;
	}
	public static CommandsEnum getEnum(int idx)
	{
		switch (idx){
		case 100:
			return SERV_HELLO;
		case 120:
			return INTRO;
		case 130:
			return ACCEPT;
		case 140:
			return DENY;
//		case 150:
//			return BCHAT_MSG;
		case 160:
			return READY;
		case 150:
			return CHAT_MSG;
		case 180:
			return UPDATE;
		case 400:
			return THR_DIES;
		case 420:
			return MOVE_DONE;
		case 430:
			return AC_NONE;
		case 440:
			return AC_PAY;
		case 450:
			return AC_BUY;
		case 460:
			return AC_SELL;
		case 470:
			return AC_MORTGAGE;
		case 480:
			return AC_UPGRADE;
		case 555:
			return END_TURN;
		case 999:
			return DISCONNECT;
			default:
				return null;
		}
		
	}
	public int idx()
	{
		return this.idx;
	}
	public String getName()
	{
		return this.name;
	}
	public int getType()
	{
		return this.type;
	}
	public boolean isFromClient()
	{
		if(this.type == 2 )
			return true;
		else
			return false;
	}
}
